package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author evan0213
 * @description 超前点播模式计费
 */
@Data
@Entity
@Table(name = "advance_model_sale")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdvanceModelSale {

	/**
	 * <b>Fields</b> id : 主键
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ADVANCE_MODEL_SALE_SEQ")
	@SequenceGenerator(name = "ADVANCE_MODEL_SALE_SEQ", allocationSize = 1, sequenceName = "ADVANCE_MODEL_SALE_SEQ")
	private Long id;

	/**
	 * <b>Fields</b> purchaseLimit : 购买限制 black_diamond,migu_dazhanbao,diamond,province_biz_gansu,province_biz_guangdong,ma,golden多个标签用英文逗号隔开
	 */
	@Column(name = "purchase_limit")
	private String purchaseLimit;

	/**
	 * <b>Fields</b> advanceTradeName : 商品名称
	 */
	@Column(name = "advance_trade_name")
	private String advanceTradeName;

	/**
	 * <b>Fields</b> advanceTradeStartTime : 模式开始时间
	 */
	@Column(name = "advance_trade_start_time")
	private String advanceTradeStartTime;

	/**
	 * <b>Fields</b> advanceTradeEndTime : 模式关闭时间
	 */
	@Column(name = "advance_trade_end_time")
	private String advanceTradeEndTime;

	/**
	 * <b>Fields</b> advanceModel : 超前模式 1 超前看  2 逐集解锁  3 直通大结局
	 */
	@Column(name = "advance_model")
	private Integer advanceModel;

	/**
	 * <b>Fields</b> advanceProductId : 产品id 手输
	 */
	@Column(name = "advance_product_id")
	private String advanceProductId;

	/**
	 * <b>Fields</b> warrantType : 执行类型 固定时长: PERIOD ,截止时间: EXPIRATION
	 */
	@Column(name = "warrant_type")
	private String warrantType;

	/**
	 * <b>Fields</b> warrantDuration : 执行时长
	 */
	@Column(name = "warrant_duration")
	private String warrantDuration;

	/**
	 * <b>Fields</b> warrantUnit : 执行单位 天: DAY
	 */
	@Column(name = "warrant_unit")
	private String warrantUnit;

	/**
	 * <b>Fields</b> invalidTime : 执行结束时间 截止时间时，不能为空
	 */
	@Column(name = "invalid_time")
	private String invalidTime;

	/**
	 * <b>Fields</b> remarks : 备注
	 */
	@Column(name = "remarks")
	private Integer remarks;

	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;

	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@Column(name = "created_time")
	private String createdTime;

	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;

	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@Column(name = "updated_time")
	private String updatedTime;

	/**
	 * <b>Fields</b> del : 删除列
	 */
	@Column(name = "del")
	private Integer del;

	public static void putTimeAndUser(AdvanceModelSale advanceModelSale) {
		if (advanceModelSale.id == null) {
			advanceModelSale.setCreatedBy(CurrentUser.currUserName());
			advanceModelSale.setCreatedTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
		}
		advanceModelSale.setUpdatedBy(CurrentUser.currUserName());
		advanceModelSale.setUpdatedTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
	}
}
